package Servlet.ComprobantePago;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import com.huellas.bean.ListadoCitasComprobanteBean;
import com.huellas.negocio.GestionComprobantes;

/**
 * Servlet implementation class ListadoCitaComprobanteServlet
 */
@WebServlet("/ListadoCitaComprobanteServlet")
public class ListadoCitaComprobanteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListadoCitaComprobanteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String code = request.getParameter("txtCodigo").toString();
		if (code.equalsIgnoreCase("")){
			code = "0";
		}
		
		int codigo = Integer.parseInt(code);
		String opcion = request.getParameter("OpcCriterio").toString();
		GestionComprobantes gc = new GestionComprobantes();
		Collection<ListadoCitasComprobanteBean>Listado = null;
		//try {
			if (opcion.equalsIgnoreCase("T")) {
				Listado = gc.ListadocitaComprobante(0, 0, opcion);
			}else {
				if (opcion.equalsIgnoreCase("C")) {
					Listado = gc.ListadocitaComprobante(0,codigo, opcion);
				}else {
					Listado = gc.ListadocitaComprobante(codigo,0, opcion);
				}
			}
			request.setAttribute("ListaCitasParaComprobantes", Listado);
			RequestDispatcher rd = request.getRequestDispatcher("ListadoCitasComprobante.jsp");
			rd.forward(request, response);
		//} catch (Exception e) {
			// TODO: handle exception
		//}
		
	}

}
